<template>
  <div>
    <el-card shadow="always">
      <el-row type="flex" :gutter="20" align="middle">
        <el-col :span="4">
          <el-cascader
            :options="optionsArea"
            :props="{
              value: 'areaCode',
              label: 'areaName',
              children: 'children',
              checkStrictly: true,
            }"
            ref="cascader"
            @change="CascaderArea"
            :show-all-levels="false"
            v-model="query.areaCode"
          ></el-cascader>
        </el-col>
        <el-col :span="4">
          <el-cascader
            clearable
            placeholder="请选择单位业态"
            v-model="bodyindustryStr"
            :options="bodyindustryList"
            @change="onCascaderChange"
            :collapse-tags="true"
            :props="{
              checkStrictly: true,
              multiple: true,
                    children:'list',
              label:'bodyIndustryRemarks',
              value:'bodyIndustryRemarks'
            }"
          ></el-cascader>
        </el-col>
        <el-col :span="4">
          <el-select
            v-model="query.remark"
            clearable
            collapse-tags
            multiple
            placeholder="请选择主体责任类型"
          >
            <el-option
              :label="item.label"
              :value="item.value"
              v-for="item in [
                {
                  label: '未设定',
                  value: '未设定',
                },
                {
                  label: '大型餐饮服务企业',
                  value: '大型餐饮服务企业',
                },
                {
                  label: '中型餐饮服务企业',
                  value: '中型餐饮服务企业',
                },
                {
                  label: '大型食品销售企业',
                  value: '大型食品销售企业',
                },
                {
                  label: '中型食品销售企业',
                  value: '中型食品销售企业',
                },
                {
                  label: '托幼机构食堂(用餐人数300以上)',
                  value: '托幼机构食堂(用餐人数300以上)',
                },
                {
                  label: '学校食堂(用餐人数500以上)',
                  value: '学校食堂(用餐人数500以上)',
                },
                {
                  label: '其他学校食堂（含托幼机构，需总监）',
                  value: '其他学校食堂（含托幼机构，需总监）',
                },

                {
                  label: '用餐（供餐）1000人以上的单位',
                  value: '用餐（供餐）1000人以上的单位',
                },
                {
                  label: '网络平台（需设置总监）',
                  value: '网络平台（需设置总监）',
                },

                {
                  label: '食用农产品批发市场',
                  value: '食用农产品批发市场',
                },
                {
                  label: '其他企业(无需设置总监)',
                  value: '其他企业(无需设置总监)',
                },
              ]"
              :key="item.value"
            ></el-option>
          </el-select>
        </el-col>
        <el-col :span="4">
          <el-select
            v-model="query.isHaveDirector"
            placeholder="是否有企业负责人"
            clearable
          >
            <el-option
              v-for="item in [
                {
                  label: '未签署',
                  value: '0',
                },
                {
                  label: '已签署',
                  value: '1',
                },
              ]"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="4">
          <el-select
            v-model="query.isHaveChiefInspector"
            placeholder="是否有食品安全总监"
            clearable
          >
            <el-option
              v-for="item in [
                {
                  label: '未签署',
                  value: '0',
                },
                {
                  label: '已签署',
                  value: '1',
                },
              ]"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-col>
        <el-col :span="4">
          <el-select
            v-model="query.isHaveFoodSafetyOfficer"
            placeholder="食品安全员是否签署"
            clearable
          >
            <el-option
              v-for="item in [
                {
                  label: '未签署',
                  value: '0',
                },
                {
                  label: '已签署',
                  value: '1',
                },
              ]"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select>
        </el-col>
      </el-row>
      <rz-height></rz-height>
      <el-row type="flex" :gutter="20" align="middle">
        <el-col :span="6">
          <el-input
            clearable
            maxlength="50"
            v-model="query.identify"
            placeholder="请输入统一社会信用代码/法人身份证号码"
          ></el-input>
        </el-col>
        <el-col :span="4">
          <el-input
            maxlength="50"
            clearable
            v-model="query.newlicenseno"
            placeholder="请输入许可证编号"
          ></el-input>
        </el-col>
        <el-col :span="4">
          <el-input
            clearable
            maxlength="50"
            v-model="query.unitname"
            placeholder="请输入单位名称"
          ></el-input>
        </el-col>
        <!-- <el-col :span="4"> -->
        <!-- <el-cascader
            clearable
            placeholder="请选择是否全部签署"
            v-model="query.isAllSigning"
            :options="bodyindustryList"
            @change="onCascaderChange"
            :collapse-tags="true"
            :props="{
              checkStrictly: true,
              multiple: true,
            }"
          ></el-cascader> -->
        <!-- <el-select
            v-model="query.isAllSigning"
            placeholder="是否全部签署"
            clearable
          >
            <el-option
              v-for="item in [
                {
                  label: '未签署',
                  value: '0',
                },
                {
                  label: '已签署',
                  value: '1',
                },
              ]"
              :key="item.value"
              :label="item.label"
              :value="item.value"
            >
            </el-option>
          </el-select> -->
        <!-- </el-col> -->
        <el-col :span="4">
          <el-select v-model="query.brisk" placeholder="请选择单位状态">
            <el-option
              :label="item.label"
              :value="item.value"
              v-for="item in [
                {
                  label: '全部',
                  value: '',
                },
                {
                  label: '活跃单位',
                  value: '1',
                },
                {
                  label: '不活跃单位',
                  value: '2',
                },
              ]"
              :key="item.value"
            >
            </el-option>
          </el-select>
        </el-col>

        <el-col :span="4">
          <el-select v-model="query.isPeople" placeholder="请选择单位状态">
            <el-option
              :label="item.label"
              :value="item.value"
              v-for="item in [
                {
                  label: '单位是否注册',
                  value: '',
                },
                {
                  label: '已注册',
                  value: '1',
                },
                {
                  label: '未注册',
                  value: '2',
                },
              ]"
              :key="item.value"
            >
            </el-option>
          </el-select>
        </el-col>

        <el-col :span="4">
          <el-select
            v-model="query.legalUnitStatus"
            placeholder="请选择执照状态"
          >
            <el-option
              :label="item.label"
              :value="item.value"
              v-for="item in [
                  {
                  value: '',
                  label: '执照状态',
                },
                {
                  value: '01',
                  label: '在业',
                },

                {
                  value: '02',
                  label: '企业直接申请注销',
                },
                {
                  value: '03',
                  label: '吊销后未注销',
                },
                {
                  value: '04',
                  label: '迁出',
                },
            
                {
                  value: '12',
                  label: '吊销后注销',
                },
                {
                  value: '13',
                  label: '个体户撤销',
                },
              ]"
              :key="item.value"
            ></el-option>
          </el-select>
        </el-col>

        <el-col :span="2">
          <el-button
            type="primary"
            @click="
              getList();
              query.page = 1;
            "
            icon="el-icon-search"
            >查询</el-button
          ></el-col
        >

        <el-col :span="2">
          <el-button type="default" @click="getExport">导出</el-button></el-col
        >
      </el-row>
      <rz-height></rz-height>

      <el-row>
        <el-col :span="24">
          <el-table
            border
            :data="tableData"
            style="width: 100%"
            stripe
            @sort-change="sortChange"
          >
         <el-table-column label="执照状态" prop="districtName" width="120">
              <template slot-scope="scope">
                 <div v-if="scope.row.legalUnitStatusStr">
                   <el-tag type="success" v-if="scope.row.legalUnitStatusStr=='在业'">{{ scope.row.legalUnitStatusStr }}</el-tag>
                   <el-tag type="danger" v-else>{{ scope.row.legalUnitStatusStr }}</el-tag>
                 </div>
                 <el-tag type="success" v-else>在业</el-tag>


                  
              </template>
            </el-table-column>
            <el-table-column label="区域街道" prop="districtName" width="180">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.districtName }}--{{ scope.row.streetName }}
                </div>
              </template>
            </el-table-column>
            <el-table-column
              label="营业执照名称"
              prop="unitName"
              width="250"
            ></el-table-column>
            <el-table-column
              label="经营者名称"
              width="250"
              prop="operatorName"
            ></el-table-column>

            <el-table-column
              label="总监企业类型"
              width="180"
              prop="operatorName"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.remark == '未设定'" style="color: #409eff">
                  {{ scope.row.remark }}
                  <span
                    class="el-icon-edit"
                    style="cursor: pointer"
                    @click="open(scope.row)"
                  ></span>
                </div>
                <div v-else>
                  {{ scope.row.remark }}
                </div>
              </template>
            </el-table-column>

            <el-table-column
              label="食安指数"
              sortable="custom"
              prop="indexScore"
              width="110"
            >
              <template slot-scope="scope">
                <div v-if="scope.row.indexScore >= 80" class="green">
                  {{ scope.row.indexScore }}
                </div>
                <div v-else-if="scope.row.indexScore > 60" class="yellow">
                  {{ scope.row.indexScore }}
                </div>
                <div v-else class="red">{{ scope.row.indexScore }}</div>
              </template>
            </el-table-column>
            <el-table-column label="单位业态" width="200" prop="bodyindustry">
              <template slot-scope="scope">
                <div>
                  {{ scope.row.bodyIndustry
                  }}{{
                    scope.row.bodyIndustryRemarks
                      ? "--" + scope.row.bodyIndustryRemarks
                      : ""
                  }}
                </div>
              </template>
            </el-table-column>
            <el-table-column
              width="180"
              label="统一社会信用代码"
              prop="identify"
            ></el-table-column>

            <el-table-column label="许可证编号" width="150" prop="newLicenseNo">
              <template slot-scope="scope">
                <div>{{ scope.row.newLicenseNo || "--" }}</div></template
              ></el-table-column
            >

            <el-table-column
              label="企业负责人"
              prop="productionaddress"
              width="150"
            >
              <template slot-scope="scope">
                <div class="green" v-if="scope.row.directorName != '未签署'">
                  {{ scope.row.directorName }}({{
                    scope.row.directorSigningDate
                  }})
                </div>
                <div class="red" v-else>未签署</div>
              </template>
            </el-table-column>
            <el-table-column
              label="食品安全总监"
              prop="productionaddress"
              width="150"
            >
              <template slot-scope="scope">
                <div
                  class="green"
                  v-if="scope.row.chiefInspectorName != '未签署'"
                >
                  {{ scope.row.chiefInspectorName }}({{
                    scope.row.chiefInspectorSigningDate
                  }})
                </div>
                <div class="red" v-else>未签署</div>
              </template>
            </el-table-column>
            <el-table-column
              label="食品安全员"
              prop="productionaddress"
              width="180"
            >
              <template slot-scope="scope">
                <div
                  class="green"
                  v-if="scope.row.foodSafetyOfficers != '未签署'"
                >
                  {{ scope.row.foodSafetyOfficers }}
                </div>
                <div class="red" v-else>未签署</div>
              </template>
            </el-table-column>

            <el-table-column label="日管控" align="center">
              <el-table-column
                label="完成数"
                width="70"
                prop="dispatchTotalSign"
              >
                <template slot-scope="scope">
                  <div
                    v-if="scope.row.dispatchTotalSign"
                    style="
                      text-decoration: underline;
                      cursor: pointer;
                      color: #1890ff;
                    "
                    @click="control('1', '日管控详情', scope.row.id, '1')"
                  >
                    {{ scope.row.dispatchTotalSign }}
                  </div>
                  <div v-else>
                    {{ scope.row.dispatchTotalSign }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="任务数" width="70">
                <template slot-scope="scope">
                  <div
                    style="
                      text-decoration: underline;
                      cursor: pointer;
                      color: #1890ff;
                    "
                    @click="control('1', '日管控详情', scope.row.id, '')"
                  >
                    {{ scope.row.dispatchTotal }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                label="完成率"
                width="90"
                prop="2"
                sortable="custom"
              >
                <template slot-scope="scope">
                  {{ scope.row.dayCompletionRate }}
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="周排查" align="center">
              <el-table-column
                label="完成数"
                width="70"
                prop="troubleshootingSign"
              >
                <template slot-scope="scope">
                  <div
                    v-if="scope.row.troubleshootingSign"
                    style="
                      text-decoration: underline;
                      cursor: pointer;
                      color: #1890ff;
                    "
                    @click="control('2', '周排查详情', scope.row.id, '1')"
                  >
                    {{ scope.row.troubleshootingSign }}
                  </div>
                  <div v-else>
                    {{ scope.row.troubleshootingSign }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="任务数" width="70" prop="troubleshooting">
                <template slot-scope="scope">
                  <div
                    style="
                      text-decoration: underline;
                      cursor: pointer;
                      color: #1890ff;
                    "
                    @click="control('2', '周排查详情', scope.row.id, '')"
                  >
                    {{ scope.row.troubleshooting }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                label="完成率"
                width="90"
                sortable="custom"
                prop="3"
              >
                <template slot-scope="scope">
                  {{ scope.row.weekCompletionRate }}
                </template>
              </el-table-column>
            </el-table-column>

            <el-table-column label="月调度" align="center">
              <el-table-column
                label="完成数"
                width="70"
                prop="controlTotalSign"
              >
                <template slot-scope="scope">
                  <div
                    v-if="scope.row.controlTotalSign"
                    style="
                      text-decoration: underline;
                      cursor: pointer;
                      color: #1890ff;
                    "
                    @click="control('3', '月调度详情', scope.row.id, '1')"
                  >
                    {{ scope.row.controlTotalSign }}
                  </div>
                  <div v-else>
                    {{ scope.row.controlTotalSign }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column label="任务数" width="70" prop="controlTotal">
                <template slot-scope="scope">
                  <div
                    style="
                      text-decoration: underline;
                      cursor: pointer;
                      color: #1890ff;
                    "
                    @click="control('3', '月调度详情', scope.row.id, '')"
                  >
                    {{ scope.row.controlTotal }}
                  </div>
                </template>
              </el-table-column>
              <el-table-column
                label="完成率"
                width="90"
                sortable="custom"
                prop="4"
              >
                <template slot-scope="scope">
                  {{ scope.row.monthCompletionRate }}
                </template>
              </el-table-column>
            </el-table-column>
            <el-table-column label="操作" prop="indexScore" width="220">
              <template slot-scope="scope">
                <el-button type="danger" size="mini" @click="edit(scope.row)"
                  >移除</el-button
                >
                <el-button type="primary" size="mini" @click="score(scope.row)"
                  >企业状况图</el-button
                >
              </template>
            </el-table-column>
          </el-table>
          <pagination
            :total="total"
            :page.sync="query.page"
            @pagination="getList"
            v-show="total"
          />
        </el-col>
      </el-row>
    </el-card>
    <rz-dialog
      :dialogVisible.sync="dialogVisible"
      :isShowConfirm="false"
      :title="title"
    >
      <inspect
        :classification="classification"
        :taskStatus="taskStatus"
        :unId="unId"
        v-if="dialogVisible"
        :clearable="true"
      ></inspect>
    </rz-dialog>

    <rz-dialog
      :dialogVisible.sync="dialogVisibleLabel"
      title="编辑单位标签"
      width="50%"
      @onconfirm="onconfirm"
    >
      <el-form ref="form" :model="sendData" label-width="160px">
        <el-row>
          <el-col :span="24">
            <el-form-item label="营业执照名称">
              {{ sendData.unitName }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="单位业态">
              {{ sendData.bodyIndustry
              }}{{
                sendData.bodyIndustryRemarks
                  ? "--" + sendData.bodyIndustryRemarks
                  : sendData.bodyIndustryRemarks
              }}
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="24">
            <el-form-item label="总监企业类型">
              <el-select
                v-model="sendData.remark"
                clearable
                placeholder="请选择总监企业类型"
              >
                <el-option
                  :label="item.label"
                  :value="item.value"
                  v-for="item in [
                    {
                      label: '大型餐饮服务企业',
                      value: '大型餐饮服务企业',
                    },
                    {
                      label: '中型餐饮服务企业',
                      value: '中型餐饮服务企业',
                    },
                    {
                      label: '大型食品销售企业',
                      value: '大型食品销售企业',
                    },
                    {
                      label: '中型食品销售企业',
                      value: '中型食品销售企业',
                    },
                    {
                      label: '托幼机构食堂(用餐人数300以上)',
                      value: '托幼机构食堂(用餐人数300以上)',
                    },
                    {
                      label: '学校食堂(用餐人数500以上)',
                      value: '学校食堂(用餐人数500以上)',
                    },
                    {
                      label: '网络平台（需设置总监）',
                      value: '网络平台（需设置总监）',
                    },
                    {
                      label: '用餐（供餐）1000人以上的单位',
                      value: '用餐（供餐）1000人以上的单位',
                    },
                  ]"
                  :key="item.value"
                ></el-option>
              </el-select>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
    </rz-dialog>

    <unit
      v-if="unitDialogVisible"
      :unitData="unitData"
      @oncancel="
        () => {
          unitDialogVisible = false;
          getList();
        }
      "
      :areaCode="query.areaCode"
    ></unit>
  </div>
</template>
<script>
import {
  groupArea,
  // viseUnitListSuper,
  // exportqueryPeopleInfoNew,
  // sysDicUnitLabel,
  // saveSuperViseUnitLabel,
  findLabelList,
} from "@/api/modules/enterprise";
import { exportGroupMealPilot } from "@/api/modules/coldLink";
import { updateSuperViseUnitLabel,findSysDicBusiness } from "@/api/modules/enterprise";

export default {
  name: "archives",
  components: {},
  created() {
    if (this.$route.query.code) {
      this.query.areaCode = this.$route.query.code;
    } else {
      this.query.areaCode = "320505000000";
    }
    // this.query.startDateCompletion = this.$moment().format("YYYY-MM-DD");
    // this.query.endDateCompletion = this.$moment().format("YYYY-MM-DD");
    this.getList();
    // this.findUnitBodyIndustryLink();
    this.findAreaListNoParentByParentCode();
    // this.unitLabel();
    this.findSysDicBusiness()
  },
  mounted() {},
  data() {
    return {
      unitDialogVisible: false,
      taskStatus: "1",
      classification: "1",
      title: "",
      unId: "",
      viewData: {},
      dialogVisible: false,
      dialogVisibleLabel: false,
      tableData: [],
      bodyindustryStr: "",
      query: {
        areaCode: "",
        bodyindustry: [],
        bodyindustryremarks: [],
        endDateRegistration: "",
        identify: "",
        isAllSigning: "",
        isHaveChiefInspector: "",
        isHaveDirector: "",
        isHaveFoodSafetyOfficer: "",
        isPage: 0,
        labelList: ["总监企业"],
        newlicenseno: "",
        page: 1,
        pageSize: 10,
        sort: "0",
        startDateRegistration: "",
        unitname: "",
        ifOut: "",
        remark: [],
        labelName: "总监企业",
        brisk: "1",
        isPeople: "",
        legalUnitStatus: "",
      },
      sendData: {
        remark: "",
        id: "",
      },
      unitData: {
        unitName: "",
        id: "",
        labelNameReplacement: "",
        remarkReplacement: "",
      },
      // time: "",
      time1: [],
      total: 0,
      // options: [],
      optionsArea: [],
      pickerOptions: {},
      bodyindustryList: [],
    };
  },
  // 方法
  methods: {
                  findSysDicBusiness(){
findSysDicBusiness().then((res) => {
        // this.optionsArea = [res.data];
        // console.log(res);
        this.bodyindustryList=res.data
      });
    },
    control(classification, title, unId, taskStatus) {
      this.classification = classification;
      this.title = title;
      this.unId = unId;
      this.taskStatus = taskStatus;
      this.dialogVisible = true;
    },
    // findFoodSafetyClassList(e) {
    //   this.query.pageIndex = e.page;
    //   this.getweiOrder();
    // },
    findAreaListNoParentByParentCode() {
      groupArea({
        params: {
          areaCode: this.query.areaCode,
        },
      }).then((res) => {
        this.optionsArea = [res.data];
      });
    },
    findUnitBodyIndustryLink() {
      this.$http.findUnitBodyIndustryLink({}).then((res) => {
        res.data.forEach((x, index) => {
          x.label = x.bodyIndustry;
          x.value = this.$_.uniqueId();
          if (x.list.length) {
            x.children = x.list.map((x, index) => ({
              label: x,
              value: this.$_.uniqueId(),
            }));
          } else {
            x.children = [{ label: x.bodyIndustry, value: this.$_.uniqueId() }];
          }
        });
        this.options = res.data;
      });
    },
    getList(e) {
      // if (e) {
      //   this.query.pageIndex = 1;
      // }
      findLabelList(this.query).then((res) => {
        this.tableData = res.data;
        this.total = res.totalCount;
      });
    },
    // 分页
    handleCurrentChange(e) {
      this.Page.pagenum = e;
      this.getweiOrder();
    },
    // 分页
    handleSizeChange(e) {
      this.Page.pagesize = e;
      this.getweiOrder();
    },
    // Cascader(e) {
    //   if (e) {
    //     this.query.bodyindustryStr = e[e.length - 1];
    //     this.options.map((x) => {
    //       x.children.map((x) => {
    //         if (x.value == e[e.length - 1]) {
    //           this.query.bodyindustry = x.label;
    //         }
    //       });
    //     });
    //   } else {
    //     this.query.bodyindustryStr = "";
    //     this.query.bodyindustry = "";
    //   }
    // },
    onCascaderChange(e) {
      // ,['食品生产经营者',"餐饮服务经营者","单位食堂","食品销售经营者"])
      if (!e.length) {
        this.query.bodyindustry = [];
        this.query.bodyindustryremarks = [];
      } else {
         this.query.bodyindustryremarks = this.$_.difference(
          this.$_.flattenDeep(e),
         this.bodyindustryList.map(x=>x.bodyIndustryRemarks)
        );
        this.query.bodyindustry = this.$_.intersection(this.$_.flattenDeep(e), this.bodyindustryList.map(x=>x.bodyIndustryRemarks));
        if (
          this.$_.intersection(this.query.bodyindustryremarks,this.bodyindustryList.filter(x=>x.bodyIndustryRemarks=='餐饮服务经营者')[0].list.map(x=>x.bodyIndustryRemarks)).length
        ) {
          this.query.bodyindustry = this.$_.pull(
            this.query.bodyindustry,
            "餐饮服务经营者"
          );
        }
        if (
          this.$_.intersection(this.query.bodyindustryremarks,this.bodyindustryList.filter(x=>x.bodyIndustryRemarks=='集中用餐单位食堂')[0].list.map(x=>x.bodyIndustryRemarks)).length
        ) {
          this.query.bodyindustry = this.$_.pull(
            this.query.bodyindustry,
            "集中用餐单位食堂"
          );
        }

        if (
          this.$_.intersection(this.query.bodyindustryremarks,this.bodyindustryList.filter(x=>x.bodyIndustryRemarks=='食品销售经营者')[0].list.map(x=>x.bodyIndustryRemarks)).length
        ) {
          this.query.bodyindustry = this.$_.pull(
            this.query.bodyindustry,
            "食品销售经营者"
          );
        }
      }

      // console.log(e);
      // if (e.length == 2) {
      //   this.query.bodyindustry = e[0];
      //   this.query.bodyindustryremarks = e[1];
      // } else if (e.length == 1) {
      //   this.query.bodyindustry = e[0];
      //   this.query.bodyindustryremarks = "";
      // } else {
      //   this.query.bodyindustry = "";
      //   this.query.bodyindustryremarks = "";
      // }
    },
    CascaderArea(e) {
      this.query.areaCode = e[e.length - 1];
    },
    // changeScore(e) {
    //   if (e) {
    //     this.query.startindexScore = e.split("-")[0];
    //     this.query.endindexScore = e.split("-")[1];
    //   } else {
    //     this.query.startindexScore = "";
    //     this.query.endindexScore = "";
    //   }
    // },
    // registrationTime(e) {
    //   if (e) {
    //     this.query.startDateRegistration = e[0];
    //     this.query.endDateRegistration = e[1];
    //   } else {
    //     this.query.startDateRegistration = "";
    //     this.query.endDateRegistration = "";
    //   }
    // },
    CompletionTime(e) {
      if (e) {
        this.query.startDateRegistration = e[0];
        this.query.endDateRegistration = e[1];
      } else {
        this.query.startDateRegistration = "";
        this.query.endDateRegistration = "";
      }
    },
    // enterprise(e) {
    //   sessionStorage.removeItem("menuSelect");
    //   sessionStorage.setItem("router", "/foodSafety/archives/archives");
    //   sessionStorage.setItem("id", e.id);
    //   sessionStorage.setItem("newLicenseNo", e.newlicenseno);
    //   this.$router.push({ path: "/enterprise/home" });
    // },
    score(e) {
      // sessionStorage.setItem("id", e.id);
      sessionStorage.setItem("newLicenseNo", e.newlicenseno);
      sessionStorage.setItem("interpretation", e.id);
      this.$router.push({
        path: "/interpretation/home?url=/directorEnterprise",
      });
    },
    getExport(e) {
      findLabelList({
        ...this.query,
        ifOut: "1",
      }).then((res) => {
        this.$downloadFiles(res.data);
        // var blob = new Blob([res], {
        //   type: "application/vnd.ms-excel;charset=utf-8",
        // });
        // var downloadElement = document.createElement("a");
        // var href = window.URL.createObjectURL(blob); //创建下载的链接
        // console.log(href);
        // downloadElement.href = href;
        // downloadElement.download =
        //   "企业档案表" + new Date().getTime() + ".xlsx"; //下载后文件名
        // document.body.appendChild(downloadElement);
        // downloadElement.click(); //点击下载
        // document.body.removeChild(downloadElement); //下载完成移除元素
        // window.URL.revokeObjectURL(href); //释放掉blob对象
        // console.log(res);
      });
    },
    getPilotExport() {
      this.query.pilotUnit = "1";
      exportGroupMealPilot({
        ...this.query,
        bodyindustryremarks: this.query.bodyindustryremarks.join(","),
        bodyindustry: this.query.bodyindustry.join(","),
      }).then((res) => {
        var blob = new Blob([res], {
          type: "application/vnd.ms-excel;charset=utf-8",
        });
        var downloadElement = document.createElement("a");
        var href = window.URL.createObjectURL(blob); //创建下载的链接
        console.log(href);
        downloadElement.href = href;
        downloadElement.download =
          "企业档案表" + new Date().getTime() + ".xlsx"; //下载后文件名
        document.body.appendChild(downloadElement);
        downloadElement.click(); //点击下载
        document.body.removeChild(downloadElement); //下载完成移除元素
        window.URL.revokeObjectURL(href); //释放掉blob对象
      });
    },
    sortChange(e) {
      if (e.prop == "indexScore") {
        if (e.order == "ascending") {
          this.query.sort = "2";
        } else if (e.order == "descending") {
          this.query.sort = "1";
        } else {
          this.query.sort = "0";
        }
      }
      if (e.prop == "2") {
        if (e.order == "ascending") {
          this.query.sort = "4";
        } else if (e.order == "descending") {
          this.query.sort = "3";
        } else {
          this.query.sort = "0";
        }
      }
      if (e.prop == "3") {
        if (e.order == "ascending") {
          this.query.sort = "6";
        } else if (e.order == "descending") {
          this.query.sort = "5";
        } else {
          this.query.sort = "0";
        }
      }
      if (e.prop == "4") {
        if (e.order == "ascending") {
          this.query.sort = "8";
        } else if (e.order == "descending") {
          this.query.sort = "7";
        } else {
          this.query.sort = "0";
        }
      }
      this.getList();
    },
    edit(e) {
      console.log(e);
      this.unitData.unitName = e.unitName;
      this.unitData.id = e.id;
      this.unitData.labelNameReplacement =
        e.remark == "其他企业(无需设置总监)" ? "特殊总监企业" : "总监企业";
      this.unitData.remarkReplacement = e.remark;

      this.unitDialogVisible = true;
      // this.$confirm("确认移除吗?", "提示", {
      //   confirmButtonText: "确定",
      //   cancelButtonText: "取消",
      //   type: "warning",
      // }).then(() => {
      //   // saveSuperViseUnitLabel([
      //   //   {
      //   //     labelName: "",
      //   //     id: e.id,
      //   //     type: "总监企业",
      //   //     unitName: e.unitName,
      //   //     updateName: sessionStorage.getItem("logname"),
      //   //     updateDepartment: sessionStorage.getItem("unitName"),
      //   //     newLicenseNo: "",
      //   //     typeA: "",
      //   //     typeAStr: "",
      //   //     regionType: "",
      //   //   },
      //   // ]).then((res) => {
      //   //   this.getList();
      //   // });

      // });
    },
    onconfirm() {
      if (this.sendData.remark == "") return this.$error("请选择总监单位类别");
      updateSuperViseUnitLabel(this.sendData).then((res) => {
        this.dialogVisibleLabel = false;
        this.$success(res.msg);
        this.getList();
      });
      // saveBackGround
    },
    // unitLabel() {
    //   sysDicUnitLabel({
    //     params: {
    //       category: "unit_lable",
    //     },
    //   }).then((res) => {
    //     this.labelData = res.data;
    //   });
    // },
    open(e) {
      this.sendData.unitName = e.unitName;
      this.sendData.id = e.id;
      this.sendData.remark = e.remark;
      this.sendData.bodyIndustry = e.bodyIndustry;
      this.sendData.bodyIndustryRemarks = e.bodyIndustryRemarks;

      this.dialogVisibleLabel = true;
    },
    // onconfirm() {
    //   let data = this.$_.cloneDeep(this.sendData);
    //   data.labelName = data.labelName.join(",");
    //   saveSuperViseUnitLabel([data]).then((res) => {
    //     this.dialogVisible = false;
    //     this.getweiOrder(1);
    //   });
    // },
  },
  // 监听属性
  watch: {},
  // 组件
  components: {
    inspect: () => import("@/views/enterprise/components/inspect"),
    unit: () => import("@/views/performance/components/unit"),
  },
  // 计算属性
  computed: {},
};
</script>

<style lang="less" scoped>
.right {
  text-align: right;
}
.el-button {
  margin-left: 20px;
}
.el-dropdown-menu {
  height: 600px;
  overflow: auto;
}
</style>
